// pages/map/map.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    longitude: "",
    latitude: "",
    marker: [{
      "latitude": "39.46772",
      "longitude": "75.99381",
      "iconPath": "/img/location.png",
      callout: {
        "content": "喀什市欢迎您",
        "color": "#124578",
        "fontSize": 30,
      }
    }, {
      "latitude": "39.465418",
      "longitude": "76.099756",
      "iconPath": "/img/location.png",
      callout: {
        "content": "深圳城",
        "color": "#124578",
        "fontSize": 30,
      }
    }],

    polyline: [
      {
        points: [{
          latitude: 39.465418,
          longitude: 76.099756,
        },{
          latitude: 39.46772,
          longitude: 75.99381,
        }],
        color: "#ff0000",
        width: 2,
        dottedLine: true,
        level: "abovelabels",
      }]
  },

  open:function(){
    let that = this;
    wx.getLocation({
      success:function(res){
        wx.chooseLocation({
          latitude: res.latitude,
          longitude: res.longitude,
          scale:15,
          success:function(res1){
            console.log(res1);
          }
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    wx.getLocation({
      success: function (e) {
        console.log(e);
        that.setData({
          longitude: e.longitude,
          latitude: e.latitude,
        })
      },
      fail: function () {
        console.log("定位失败！");
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})